package com.yanfan.modbus.frame;


import com.yanfan.modbus.code.FunctionCode;
import com.yanfan.modbus.exception.ModbusTransportException;
import com.yanfan.modbus.frame.abs.ModbusResponse;
import io.netty.buffer.ByteBuf;


public class ReadExceptionStatusResponse extends ModbusResponse {
    private byte exceptionStatus;

    public ReadExceptionStatusResponse(int slaveId) throws ModbusTransportException {
        super(slaveId);
    }

    public ReadExceptionStatusResponse(int slaveId, byte exceptionStatus) throws ModbusTransportException {
        super(slaveId);
        this.exceptionStatus = exceptionStatus;
    }


    @Override
    public byte getFunctionCode() {
        return FunctionCode.READ_EXCEPTION_STATUS;
    }


    @Override
    protected void readResponse(ByteBuf buf) {
        exceptionStatus = buf.readByte();
    }


    @Override
    protected void writeResponse(ByteBuf queue) {
        queue.writeByte(exceptionStatus);
    }


    public byte getExceptionStatus() {
        return exceptionStatus;
    }
}
